package com.gitee.wsl.net.ssdp

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filter

/**
 * Notification from UPnP device
 * @param usn       - unique service name
 * @param location  - location of the device
 * @param server    - server details of the device (e.g. “unix/5.1 UPnP/2.0 MyProduct/1.0”)
 * @param ttl       - time to live of the notification
 */
data class AddNotification(
    val usn: String,
    val location: String,
    val server: String,
    val ttl: Long
){
    companion object {
        fun Flow<AddNotification>.validateNotification() = this.filter { it.ttl > System.currentTimeMillis() }
    }
}